<template>
	<view>

			<view class="wrapper">
				
				
				<view class="fill_header">
					<view class="fill_header_title">提醒</view>
					<view class="fill_info_cont clearfix remind ">提币申请成功后24小时内到账,提币手续费为{{userinfo.tibishouxvfei}}</view>		
								
				
				</view>
				
				
				<view class="cont">
					<view class="fill_info_line">
						<view class="fill_info_title">DTSM余额</view>
						<view class="fill_info_cont clearfix">{{ userinfo.uLixiSum }}</view>
					</view>
				</view>
				
				<view class="cont">
					<view class="fill_info_line" >
						<view class="fill_info_title">锁仓地址(点击地址复制)</view>
						<view class="fill_info_cont clearfix"    @click="copyTxt(userinfo.upAddress)"> {{ userinfo.upAddress }} </view>
					</view>
				</view>
				

				<view class="cont">
					<view class="fill_info_line">
						<view class="fill_info_title">ETH（DTSM）地址</view>
						<view class="fill_info_cont clearfix"><input type="text" v-model="changeInfo.uAddress"  :disabled="changeInfo.uAddress != ''" placeholder="请输入ETH(DTSM)地址,长按粘贴" /></view>
					</view>
				</view>
				
				

				<view class="cont">
					<view class="fill_info_line">
						<view class="fill_info_title">提币数量</view>
						<view class="fill_info_cont clearfix"><input type="number" v-model="changeInfo.money" placeholder="请输入数量" /></view>
					</view>
				</view>
				
				
				<view class="cont" v-if="!changeInfo.img1">
					<view class="fill_info_line">
						<view class="fill_info_title">买入DTSM截图</view>
						<view class="fill_info_cont clearfix"> 
							<view class="photo_sign" @click="upload(1)">
								<image src="../../static/icon/plus.png" v-model="changeInfo.img1" mode="" class="photo_icon"></image>
								<view class="photo_text_b">上传图片</view>
								<view class="photo_text_s">仅支持JPG,PNG,JPEG</view>
								<view class="photo_text_s">BMP格式文件</view>
							</view>
						</view>
					</view>
				</view>
				
				
				<view class="cont" v-if="changeInfo.img1">
					<image :src="getimg + changeInfo.img1"></image>
					</view>
				
				
				
				<view class="cont" v-if="!changeInfo.img2">
					<view class="fill_info_line">
						<view class="fill_info_title">充入指定账户截图</view>
						<view class="fill_info_cont clearfix"> 
							<view class="photo_sign" @click="upload(2)">
								<image src="../../static/icon/plus.png" v-model="changeInfo.img2" mode="" class="photo_icon"></image>
								<view class="photo_text_b">上传图片</view>
								<view class="photo_text_s">仅支持JPG,PNG,JPEG</view>
								<view class="photo_text_s">BMP格式文件</view>
							</view>
						</view>
					</view>
				</view>
				
				
				<view class="cont" v-if="changeInfo.img2">
					<image :src="getimg + changeInfo.img2"></image>
					</view>
		
				
				<view class="submit_btn_cont"><button :class="issubmit ? 'nosubmit_btn' : 'submit_btn'" @click="submit" :disabled="issubmit">提交</button></view>
			</view>

	</view>
</template>

<script>
import { CUser } from '@/common/cache/user.js';
import validate from '@/common/ys-validate.js';
import util from '@/common/publicfunction.js';
var cache_user = new CUser();

export default {
	data() {
		return {
			changeInfo: {
				
				img1:'',
				img2:''
				
			},
getimg: this.$getimg,
			issubmit: false,
			userinfo: {}
		};
	},

	onLoad() {
		this.getInfo();
	},

	onPullDownRefresh() {
		// 下拉监听事件
		this.getInfo();
		setTimeout(function() {
			uni.stopPullDownRefresh();
		}, 1000);
	},

	computed: {},
	methods: {
		getInfo(e) {
			this.$api.http.post('assistance/moneychange/getTiBiInfo').then(res => {
				if (res.status == 200) {
					this.userinfo = res.data;
					this.changeInfo.uAddress = res.data.uAddress || '';
				} else {
					this.$api.msg('获取失败');
					return false;
				}
			});
		},
copyTxt(data) {
			util.copyTxt(data);
		},
		submit() {
			if (!validate.isNumber(this.changeInfo.money)) {
				this.$api.msg('输入金额有误');
				return false;
			}

			if (parseFloat(this.changeInfo.money) > parseFloat(this.userinfo.uLixiSum)) {
				this.$api.msg('您的提出金额不足，余额' + this.userinfo.uLixiSum);
				return false;
			}

			if (!this.changeInfo.uAddress) {
				this.$api.msg('请输入地址');
				return false;
			}
			
			if (!this.changeInfo.img1) {
				this.$api.msg('请上传充值图片');
				return false;
			}
			
			
			if (!this.changeInfo.img2) {
				this.$api.msg('请输入锁仓图片');
				return false;
			}
			
			

			this.issubmit = true; //禁用按钮
			this.$api.http.post('assistance/moneychange/TiBi', this.changeInfo).then(res => {
				if (res.status == 200) {
					//成功执行
					uni.showToast({
						icon: 'none',
						title: res.msg,
						mask: true,
						success() {
							setTimeout(() => {
								uni.navigateBack();
							}, 1000);
						}
					});
				} else {
					this.issubmit = false; //启用按钮
					uni.showToast({
						icon: 'none',
						title: res.msg,
						mask: true
					});

					return false;
				}
			});
		},
		upload: function(no) {
			var _self = this;
			uni.chooseImage({
				count: 1,
				sizeType: ['compressed'], //可以指定是原图还是压缩图，默认二者都有 //'original',
				sourceType: ['album'], //从相册选择
				success: function(res) {
					const tempFilePaths = res.tempFilePaths;
					const uploadTask = uni.uploadFile({
						url: _self.getimg + '/index/upload/uploadImgNoData',
						filePath: tempFilePaths[0],
						name: 'img',
						formData: {
							use: 'payimg',
							back: 'idurl'
						},
						success: uploadFileRes => {
							var res = JSON.parse(uploadFileRes.data);
		
							if (res.status == 200) {
								
								_self.$api.msg('上传成功');
								if(no==1)
									_self.changeInfo.img1 = res.data.url;
									else
									_self.changeInfo.img2 = res.data.url;
									
							
								//_self.loadpic = _self.getimg + _self.dataInfo.img;
								
							} else _self.$api.msg(res.msg);
						}
					});
		
					/* uploadTask.onProgressUpdate(function (res) {
		 
			
		 }); */
				},
				error: function(e) {
					console.log(e);
				}
			});
		}
	}
};
</script>

<style lang="scss">
.remind {
	color: #f1c013;
	font-size: 26upx;
}

.clearfix {
	zoom: 1;
	display: block;
}

.noShow {
	display: none;
}

.clearfix:after {
	content: '.';
	visibility: hidden;
	display: block;
	height: 0;
	clear: both;
}




	.wrapper {
		
		
		background-color: #f5f5f5;
		height: 100vh;
		padding: 20upx;
		
		.fill_header {
			border-radius: 5upx;
			background-color: #ffffff;
			padding: 40upx;
			margin-bottom: 20upx;
			.fill_header_title {
				font-size: 26upx;
			}
			.fill_header_cont {
				margin-top: 30upx;
				.photo_img_cont {
					border: 1upx solid hsla(0, 0%, 60%, 0.3);
					width: 120upx;
					height: 120upx;
					padding: 20upx;

					.photo_img {
						width: 80upx;
						height: 80upx;
					}
				}
			}
		}

		.cont {
			border-radius: 5upx;
			background-color: #ffffff;
			padding: 40upx;

			.fill_info_line {
				margin-top: 30upx;

				.fill_info_title {
					font-size: 26upx;
				}

				.fill_info_cont {
					position: relative;
					border-bottom: 1upx solid hsla(0, 0%, 60%, 0.3);

					.pwdInput {
						font-size: 26upx;
						height: 80upx;
						line-height: 80upx;
						border: none;
						display: block;
						outline: none;
					}

					.pwd_icon {
						width: 85upx;
						height: 85upx;
						-webkit-transform: scale(0.4);
						transform: scale(0.4);
						position: absolute;
						top: 0;
						right: 0;
					}
				}
				.fill_info_another {
					border-bottom: 1upx solid hsla(0, 0%, 60%, 0.3);
					margin-top: 24upx;
					label {
						font-size: 14upx;
					}
				}
				.checkbox_line {
					padding: 0 0px 14px;
					.uni-input {
						text-indent: 0;
						background: #ffffff;
					}
				}
			}

			.fill_info_line:first-child {
				margin-top: 0;
			}
		}
	}

	.submit_btn_cont {
		margin-top: 20upx;

		.submit_btn {
			border-radius: 5upx;
			color: #ffffff;
			font-size: 26upx;
			background: linear-gradient(90deg, #4e8cff, #2f79ff);
		}

		.nosubmit_btn {
			border-radius: 5upx;
			color: #ffffff;
			font-size: 26upx;
			background: linear-gradient(90deg, #c6c5c5, #cdced0);
		}
	}
	
	
	.photo_sign {
		background-color: #fafafa;
		text-align: center;
		width: 240upx;
		height: 240upx;
		color: #dcdcdc;
		.photo_icon {
			width: 60upx;
			height: 60upx;
			margin: 26upx 0 10upx;
		}
		.photo_text_b {
			font-size: 18upx;
		}
		.photo_text_s {
			margin-top: 6upx;
			font-size: 16upx;
		}
		.photo_preview {
			width: 100%;
			height: 100%;
		}
	}
	
	
	
	.copy_btn {
		border-radius: 5upx;
		color: #ffffff;
		font-size: 14upx;
		background: linear-gradient(90deg, #4e8cff, #2f79ff);
	}
	

</style>
